package com.ruoyi.web.controller.system;

import java.util.HashMap;
import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.system.service.NoticeService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.Noticetype;
import com.ruoyi.system.service.INoticetypeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 通知类型Controller
 * 
 * @author lfm
 * @date 2024-08-12
 */
@RestController
@RequestMapping("/system/noticetype")
public class NoticetypeController extends BaseController
{
    @Autowired
    private INoticetypeService noticetypeService;
    /**z`
     * 查询通知类型列表
     */
    @PreAuthorize("@ss.hasPermi('system:noticetype:list')")
    @GetMapping("/list")
    public TableDataInfo list(Noticetype noticetype)
    {
        startPage();
        List<Noticetype> list = noticetypeService.selectNoticetypeList(noticetype);
        return getDataTable(list);
    }

    /**
     * 导出通知类型列表
     */
    @PreAuthorize("@ss.hasPermi('system:noticetype:export')")
    @Log(title = "通知类型", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Noticetype noticetype)
    {
        List<Noticetype> list = noticetypeService.selectNoticetypeList(noticetype);
        ExcelUtil<Noticetype> util = new ExcelUtil<Noticetype>(Noticetype.class);
        util.exportExcel(response, list, "通知类型数据");
    }

    /**
     * 获取通知类型详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:noticetype:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(noticetypeService.selectNoticetypeById(id));
    }

    /**
     * 新增通知类型
     */
    @PreAuthorize("@ss.hasPermi('system:noticetype:add')")
    @Log(title = "通知类型", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Noticetype noticetype)
    {
        return toAjax(noticetypeService.insertNoticetype(noticetype));
    }

    /**
     * 修改通知类型
     */
    @PreAuthorize("@ss.hasPermi('system:noticetype:edit')")
    @Log(title = "通知类型", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Noticetype noticetype)
    {
        return toAjax(noticetypeService.updateNoticetype(noticetype));
    }

    /**
     * 删除通知类型
     */
    @PreAuthorize("@ss.hasPermi('system:noticetype:remove')")
    @Log(title = "通知类型", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(noticetypeService.deleteNoticetypeByIds(ids));
    }
}
